<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class eventoDetalle extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('eventoM');
		
	}
	
	public function index()
	{	
		$this->load->model('eventoM');
		$id = $_GET["num"];
		$data2['evento'] = $this->eventoM->buscar($id);
		if($this->session->userdata('logueado')){
			$data = array();
			$data['nombre'] = $this->session->userdata('nombre');
			$this->load->view('headerAdmin', $data);
		}else{
			redirect('usuarios/iniciar_sesion');
		}
		$this->load->view('detalleEvento', $data2);
		$this->load->view('footerAdmin');

	}

	public	function agregar(){
		$this->load->library('form_validation');
		$this->load->model('eventoM');
		$id = $this->input->post('id');
		$evento = array(
					'nombre' => $this->input->post('nombre'),
					'descripcion' => $this->input->post('descripcion'),
					'fecha' => $this->input->post('fecha'),
					'cant_participantes' => $this->input->post('part'),
					'hora' => $this->input->post('hora'),
				);
		$id_generado = $this->eventoM->edit($id,$evento);
		
		redirect('/eventosAdmin');
		exit();
	}

	public function modificar(){
		$id = $this->input->post('id');
		/*$evento = $this->eventoM->buscar($id);*/
		$new = array(
					'nombre' => $this->input->post('nombre'),
					'descripcion' => $this->input->post('descripcion'),
					'fecha' => $this->input->post('fecha'),
					'cant_participantes' => $this->input->post('part'),
					'hora' => $this->input->post('hora'),
				);
		$this->load->library('form_validation');
		$this->load->model('eventoM');		
		
		$ev= $this->eventoM->edit($id, $new);
		redirect('/eventosAdmin');
		exit();

	}
}

?>